<?php


use models\Business\Delivery;
use Yaf\Registry;

class DeliveryController extends ApiBaseController
{

    /**
     *
     * @SWG\Get(
     *     path="/v3/delivery/list",
     *     tags={"物流模块"},
     *     summary="获取快递公司信息",
     *     description="
     * page 必须参数 页码 固定值:1
     * page_size 必须参数 每页显示条数 固定值:999
     * sort 必须参数 排序方式 可选值:desc降序、asc生序
     * order 必须参数 排序字段 固定值 id",
     *     @SWG\Parameter(
     *          name="Authorization",
     *          description="Authorization 登录接口返回的jwt字段的值",
     *          in="header",
     *          required=true,
     *          type="string"
     *     ),
     *     @SWG\Parameter(
     *          name="secret",
     *          description="签名",
     *          in="query",
     *          required=true,
     *          type="string"
     *     ),
     *     @SWG\Response(
     *         response="200",
     *         description="请求成功",
     *         @SWG\Schema(type="object", ref="#/definitions/deliveryListData")
     *     ),
     *     @SWG\Response(
     *         response="400",
     *         description="签名不存在或无效签名"
     *     ),
     *     @SWG\Response(
     *         response="401",
     *         description="jwt无效或过期，需要登录"
     *     ),
     *     @SWG\Response(
     *         response="403",
     *         description="无权访问"
     *     ),
     *     @SWG\Response(
     *         response="404",
     *         description="找不到数据"
     *     )
     * )
     */
    public function listAction() {
        $parameters = Registry::get('parameters');

        $delivery_list = Delivery::getDeliveryList($parameters);

        return $this->_responseJson($delivery_list);
    }

    /**
     * @SWG\Get(
     *     path="/v3/delivery/{order_sn}/info",
     *     tags={"订单模块"},
     *     summary="获取指定订单的物流信息",
     *     description="
     * timestamp 必须参数 当前时间戳 14位
     * is_refund 非必须参数 查询退货物流信息时该参数必须且为1",
     *     @SWG\Parameter(
     *          name="Authorization",
     *          description="Authorization 登录接口返回的jwt字段的值",
     *          in="header",
     *          required=true,
     *          type="string"
     *     ),
     *     @SWG\Parameter(
     *          name="order_sn",
     *          description="/v3/order/list接口返回的sn字段的值",
     *          in="path",
     *          required=true,
     *          type="string"
     *     ),
     *     @SWG\Parameter(
     *          name="secret",
     *          description="加密字符串",
     *          in="query",
     *          required=true,
     *          type="string"
     *     ),
     *     @SWG\Response(
     *         response="200",
     *         description="请求成功",
     *         @SWG\Schema(type="object", ref="#/definitions/orderDeliveryListData")
     *     ),
     *     @SWG\Response(
     *         response="400",
     *         description="签名不存在或无效签名"
     *     ),
     *     @SWG\Response(
     *         response="401",
     *         description="jwt无效或过期，需要登录"
     *     ),
     *     @SWG\Response(
     *         response="403",
     *         description="无权访问"
     *     ),
     *     @SWG\Response(
     *         response="404",
     *         description="找不到数据"
     *     )
     * )
     */
    public function infoAction() {
        $parameters = Registry::get('parameters');

        $delivery_detail = Delivery::getDeliveryDetailByOrderSn($parameters);

        return $this->_responseJson(['data' => $delivery_detail]);
    }

}
